﻿@using hc.epm.DataModel.Business;
@using hc.epm.Common
@using hc.Plat.Common.Extend

@model List<Epm_Approver>

@{
    ViewBag.Title = "我的待办";
    Layout = "~/Views/Shared/_LayoutPersonInfo.cshtml";
}

<style>
    .layui-laypage span {
        background-color: #fff0;
    }

    #main tbody tr td {
        color: #666;
    }
</style>

<div class="issue">
    <div class="search">
        <form id="mainForm" method="get">
            <input type="text" id="name" name="name" placeholder="输入你要搜索的项目" value="@ViewBag.Name" />
            <input type="submit" value="搜索" class="pr" />
        </form>
    </div>
    <table>
        <thead>
            <tr>
                <td width="70">序号</td>
                <td>待办项目</td>
                <td width="100">提交人</td>
                <td width="120">提交日期</td>
                <td width="100">待办状态</td>
            </tr>
        </thead>
        <tbody>
            @{
                int index = (ViewBag.pageIndex - (ViewBag.pageIndex - 1)) * ((ViewBag.pageIndex - 1) * 10);
            }
            @if (Model != null && Model.Any())
            {
                foreach (var item in Model)
                {
                    index++;
                    <tr>
                        <td>@index</td>
                        <td>
                            @switch ((BusinessType)(Enum.Parse(typeof(BusinessType), item.BusinessTypeNo)))
                            {
                                case BusinessType.Model:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Bim/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Bim/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Contract:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Contract/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Contract/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Change:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Change/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Change/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Draw:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Draw/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Draw/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Visa:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Visa/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Visa/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.SecurityCheck:
                                   if (item.Action == SystemRight.Rectif.ToString())
                                    {
                                        <a href="/Monitor/DetailAQ?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else 
                                    {
                                        <a href="/Monitor/UploadRectifyResult?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Dangerous:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Work/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Work/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.DelayApply:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/DelayPlan/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/DelayPlan/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Equipment:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Material/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Material/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Track:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Materiel/Edit?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Materiel/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Plan:
                                    if (item.Action == SystemRight.UnCheck.ToString())
                                    {
                                        <a href="/Project/MilestonePlan?projectId=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    else
                                    {
                                        <a href="/Project/MilestonePlan?projectId=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    }
                                    break;
                                case BusinessType.Question:
                                    <a href="/Question/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    break;
                                case BusinessType.Log:
                                    <a href="/SupervisorLog/Detail?id=@item.BusinessId" data-module="Model" data-right="Info">@item.Title</a>
                                    break;
                                case BusinessType.Project:
                                    <a href="/Project/ProjectISP?projectId=@item.ProjectId" data-module="ConProject" data-right="Info">@item.Title</a>
                                    break;
                                case BusinessType.Completed:
                                    <a href="/CompletionAcceptance/Detail?id=@item.BusinessId" data-module="ConProject" data-right="Info">@item.Title</a>
                                    break;
                                default:
                                    break;
                            }
                        </td>
                        <td>@item.SendUserName</td>
                        <td>@string.Format("{0:yyyy-MM-dd}", item.SendTime)</td>
                        <td>@(!item.IsApprover.Value ? "未处理" : "已处理")</td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="5">暂无数据</td>
                </tr>
            }

        </tbody>
    </table>
    <div id="page" style="text-align:right; margin-right:5px; margin-bottom:50px;">
        <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
            <a href="javascript:;" class="layui-laypage-prev layui-disabled" data-page="0">上一页</a>
            <span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>1</em></span>
            <a href="javascript:;" class="layui-laypage-next layui-disabled" data-page="2">下一页</a>
            <span class="layui-laypage-skip">
                到第<input type="text" min="1" value="1" class="layui-input">页
                <button type="button" class="layui-laypage-btn">确定</button>
            </span>
            <span class="layui-laypage-count">共 6 条</span>
        </div>
    </div>
</div>
@section scripts
{
    <script type="text/javascript">
        layui.use(['layer', 'form', 'element', 'laypage'], function () {
            var layer = layui.layer, form = layui.form, element = layui.element, $ = layui.jquery, laypage = layui.laypage;
            //分页
            laypage.render({
                elem: 'page',
                count: '@ViewBag.Total',
                curr: '@ViewBag.pageIndex',
                layout: ['prev', 'page', 'next', 'skip', 'count'],
                jump: function (obj, first) {
                    if (!first) {
                        var curr = obj.curr;
                        var search = $("form").serialize();
                        window.location.href = "/Home/MyJob?pageIndex=" + curr + "&name=" + $('#name').val();
                    }
                }
            });
        });
    </script>
}
